package com.webmall.servlet.user;

/**
 * 用于验证码输入验证
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/UserVertifyChecked")
public class UserVertifyChecked extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        String userCode = request.getParameter("code");
        System.out.println(userCode);

        HttpSession session = request.getSession();
        String  trueCode = (String) session.getAttribute("code");//在导入的codeSevlet中存到了code里

        PrintWriter out = response.getWriter();
        if (trueCode.equals(userCode)){

            out.print("true");
        }else {
            out.print("false");
        }



    }
}
